package com.guli.gulimall.gulimallmembers.controller;

import java.util.Arrays;
import java.util.Map;

import com.guli.gulimall.gulimallmembers.feign.CouponFeignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.guli.gulimall.gulimallmembers.entity.MemberEntity;
import com.guli.gulimall.gulimallmembers.service.MemberService;
import com.guli.common.utils.PageUtils;
import com.guli.common.utils.R;



/**
 * 会员
 *
 * @author zouzhi
 * @email 1245268075@qq.com
 * @date 2022-04-03 14:51:29
 */
@RestController
@RequestMapping("gulimallmembers/member")
@Api(value = "MemberController接口",tags = "会员服务接口")
public class MemberController {
    @Autowired
    private MemberService memberService;
    @Autowired
    CouponFeignService couponFeignService;

    @ApiOperation("会员优惠列表信息")
    @GetMapping("/menber/list")
    public R menberCoupons(){
        return this.couponFeignService.menberCoupons();
    }

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = memberService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		MemberEntity member = memberService.getById(id);

        return R.ok().put("member", member);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody MemberEntity member){
		memberService.save(member);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    public R update(@RequestBody MemberEntity member){
		memberService.updateById(member);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		memberService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
